﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using Microsoft.ComplexEventProcessing;
using Microsoft.ComplexEventProcessing.Extensibility;
using Microsoft.ComplexEventProcessing.Linq;

namespace $Namespace$
{
    /// <summary>
    /// Static class with UDA extensions
    /// </summary>
    public static class $UDAExtensionClassName$
    {
        /// <summary>
        /// Extension method for the $itemrootname$ UDA.
        /// </summary>
        /// <typeparam name="T">Payload type of the stream.</typeparam>
        /// <param name="window">Window to be passed to the UDA</param>
        /// <param name="map">Mapping from the payload to a float field in the payload.</param>
        /// <returns>Aggregation result.</returns>
        [CepUserDefinedAggregate(typeof($UDAClassName$))]
        public static float $safeitemrootname$<T>(this CepWindow<T> window, Expression<Func<T, float>> map)
        {
            throw CepUtility.DoNotCall();
        }
    }

    
$if$ ($TimeSensitive$ == true)
    /// <summary>
    /// $itemrootname$ user defined aggregate implementation
    /// </summary>
    public class $UDAClassName$ : CepTimeSensitiveAggregate<float, float>
    {
        /// <summary>
        /// Computes the aggregation over a window.
        /// </summary>
        /// <param name="events">Set of events contained in the window.</param>
        /// <param name="windowDescriptor">Provides temporal information about the window containing the events.</param>
        /// <returns>Aggregation result.</returns>
        public override float GenerateOutput(IEnumerable<IntervalEvent<float>> events, WindowDescriptor windowDescriptor)
        {
            float value = 0;
            //TODO: Implementation of logic to return value.
            return value; 

        }
    }
$else$
    /// <summary>
    /// $itemrootname$ user defined aggregate implementation
    /// </summary>
    public class $UDAClassName$ : CepAggregate<float, float>
    {
        /// <summary>
        /// Computes the aggregation over a window.
        /// </summary>
        /// <param name="source">Set of events contained in the window.</param>
        /// <returns>Aggregation result.</returns>
        public override float GenerateOutput(IEnumerable<float> source)
        {
            float value = 0;

            return value;
        }

    }
$endif$
}